package jm.data.structure.queue;

import java.util.Comparator;

/**
 * @Description 优先级队列测试
 * @date 2022/4/30 14:52
 */
public class PriorityQueueMain {

    public static void main(String[] args) {

        java.util.PriorityQueue<Person> ps = new java.util.PriorityQueue<>();

        PriorityQueue<Person> queue = new PriorityQueue<>(new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o1.getLevel() - o2.getLevel();
            }
        });
        queue.enQueue(new Person("a",10));
        queue.enQueue(new Person("b",1));
        queue.enQueue(new Person("c",2));
        queue.enQueue(new Person("d",999));

        while (!queue.isEmpty()){
            System.out.println(queue.deQueue());
        }
    }
}
